home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 April / april_2001.iso / intercd / root / ^Palm / Games / eCross / src / levels / LevelsMaker.template < prev    next >
Encoding:
Text File  |  2000-07-27  |  932 b   |  44 lines

  1. // purpose: creates a database of levels for eCross
  2.  
  3. import waba.io.*;
  4. import waba.ui.*;
  5.  
  6. public class LevelsMaker extends MainWindow
  7. {
  8.   // the creator ID of the software
  9.   private static final String CREATOR_ID = "eCrs";
  10.   // levels array
  11.   private static final byte[][] LEVELS =
  12.   {%TEMPLATE%
  13.   };
  14.  
  15.   // creates a new catalog
  16.  
  17.   public void onStart()
  18.   {
  19.     Catalog c = new Catalog("eCross Levels." + CREATOR_ID + ".eCrs", Catalog.READ_ONLY);
  20.     if (c.isOpen())
  21.       c.delete();
  22.  
  23.     c = new Catalog("eCross Levels." + CREATOR_ID + ".eCrs", Catalog.CREATE);
  24.     if (!c.isOpen())
  25.       return;
  26.  
  27.     for (int i = 0; i < LEVELS.length; i++)
  28.     {
  29.       int len = LEVELS[i].length;
  30.       if (c.addRecord(len + 2) == -1)
  31.         return;
  32.  
  33.       // level
  34.       if (c.writeBytes(LEVELS[i], 0, len) != len)
  35.         return;
  36.     }
  37.  
  38.     c.close();
  39.     exit(0);
  40.   }
  41. }
  42.  
  43. // End of LevelsMaker.java
  44.